<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>ArcGIS JavaScript API: featureserver</title>
<link rel="stylesheet" type="text/css" href="http://127.0.0.1:88/arcgisjsapi4/arcgis_js_api/library/4.8/dijit/themes/tundra/tundra.css" />
<link rel="stylesheet" type="text/css" href="http://127.0.0.1:88/arcgisjsapi4/arcgis_js_api/library/4.8/esri/css/main.css" />
<script type="text/javascript"> 
	var djConfig = { parseOnLoad: true };
</script> 

<script type="text/javascript" src="http://127.0.0.1:88/arcgisjsapi4/arcgis_js_api/library/4.8/dojo/dojo.js"></script>
<script type="text/javascript" src="js/jquery-1.10.2.js"></script>
<script type="text/javascript"> 
//dojo.require("dijit.layout.BorderContainer");
//dojo.require("dijit.layout.ContentPane");
//dojo.require("esri.map");
//dojo.require("esri.layers.ArcGISImageServiceLayer");
//dojo.require("esri.layers.ImageServiceParameters");
//dojo.require("esri.layers.ArcGISImageServiceVectorLayer")
//dojo.require("esri.renderers.VectorFieldRenderer")
//dojo.require("esri.renderers.SimpleRenderer")
var map;
function AddDynamicLayer1() {
    alert(map.graphicsLayerIds.length);
    //map.removeAllLayers();
            for(var j = 0; j < map.graphicsLayerIds.length; j++) {
                alert(map.graphicsLayerIds[j]);
                var layer = map.getLayer(map.graphicsLayerIds[j]);
                map.removeLayer(layer);
                //var layer = map.getLayer(map.layerIds[j]);
                //alert(layer.id + ' ' + layer.opacity + ' ' + layer.visible);
            }
}
/*function AddDynamicLayer1() {
            
            var layerName, dataSource, layerSource, options, drawingOptions, dynamicLayerInfos;
 
            // layer name in the workspace
            layerName = "NMG15012100001_2011";
            // get existing layer info
            // lakes info will be appended to this object so it shows up in the map service image
            //
            // only use createDynamicLayerInfosFromLayerInfos
            // if layers haven't been re-ordered yet
            if (!dynamicLayerInfos) {
                dynamicLayerInfos = map.getLayer("mymaplayer").createDynamicLayerInfosFromLayerInfos();
            }
 
            // create a new dynamic layer info object for the lakes layer
            var dynamicLayerInfo = new esri.layers.DynamicLayerInfo();
            dynamicLayerInfo.id = dynamicLayerInfos.length;
            dynamicLayerInfo.name = layerName;
            // can also set things like min/max scale to specify scale
            // dependency on the new dynamic layer
 
            // create a table data source to access the lakes layer
            dataSource = new esri.layers.TableDataSource();
            dataSource.workspaceId = "MyFileGDBWorkspaceID"; // not exposed via REST, sad face :(
            dataSource.dataSourceName = layerName;
            // and now a layer source
            layerSource = new esri.layers.LayerDataSource();
            layerSource.dataSource = dataSource;
            dynamicLayerInfo.source = layerSource;
            dynamicLayerInfos.push(dynamicLayerInfo);
            // set new infos, but don't refresh
            // map will be updated when the drawing options are set
            map.getLayer("mymaplayer").setDynamicLayerInfos(dynamicLayerInfos, true);
            var renderer = new esri.renderer.SimpleRenderer(new esri.symbol.SimpleFillSymbol().setOutline(new esri.symbol.SimpleLineSymbol().setWidth(0.1).setColor(new esri.Color([255, 0, 0]))));
            var renderer1 = new esri.renderer.SimpleRenderer(new esri.symbol.SimpleFillSymbol("solid", new esri.symbol.SimpleLineSymbol("solid", new dojo.Color([255, 0, 255, 0.75]),5),new dojo.Color([255, 0, 255, 0.75]))); // fuchsia lakes!
            drawingOptions = new esri.layers.LayerDrawingOptions();
            drawingOptions.renderer = renderer;
            drawingOptions1 = new esri.layers.LayerDrawingOptions();
            drawingOptions1.renderer = renderer1;
            options = [];
            //options[0] = drawingOptions;
            options[1] = drawingOptions;
 
            map.getLayer("mymaplayer").setLayerDrawingOptions(options);

            if (map.getLayer("mymaplayer").loaded) {        
                 buildLayerList(map.getLayer("mymaplayer"));              
             }else{
                 dojo.connect(map.getLayer("mymaplayer"),"onLoad",buildLayerList);
             } 
 
        }*/

function buildLayerList(layer) {
             var infos = layer.layerInfos, info;
             var items = [];
             for (var i=0,j=infos.length;i<j;i++) {
                 info = infos[i];
                 //if (info.defaultVisibility) {
                 //    visible.push(info.id);
                 //}
                 items[i] = "<input type='checkbox' class='list_item' checked='" + (info.defaultVisibility ? "checked" : "") + "' id='" + info.id +"' onclick='updateLayerVisibility();'/><label for='" +info.id+ "'>" +info.name+ "</label>";          
             }
             dojo.byId("layer_list").innerHTML = items.join();
             
             layer.setVisibleLayers(visible);
             map.addLayer(layer);
         
         }
         
         function updateLayerVisibility() {
             var inputs = dojo.query(".list_item"), input;
             visible = [];
             for (var i=0,j=inputs.length;i<j;i++) {
                 if(inputs[i].checked) {
                     visible.push(inputs[i].id);
                 }           
             }
             map.getLayer("mymaplayer").setVisibleLayers(visible);
         
         }


function init() {
     require([ 
            "esri/TimeExtent",
            "esri/layers/FeatureLayer",  
            "esri/renderers/SimpleRenderer",  
            //"esri/renderers/UniqueValueRenderer"
            "esri/renderers/UniqueValueRenderer",
            "esri/Color",  
            "esri/symbols/SimpleFillSymbol",  
            "esri/symbols/SimpleLineSymbol",
            "esri/layers/LayerDataSource",
            "esri/layers/TableDataSource"
        ], function(TimeExtent,FeatureLayer,SimpleRenderer,UniqueValueRenderer,Color,SimpleFillSymbol,SimpleLineSymbol,LayerDataSource,TableDataSource) {  
            //var layer = new esri.layers.ArcGISDynamicMapServiceLayer("http://localhost:6080/arcgis/rest/services/featureserver/MapServer");
          	map = new esri.Map("map");

            var dataSource = new TableDataSource();
            dataSource.workspaceId = "MyFileGDBWorkspaceID";
            dataSource.dataSourceName = "NMG15012100001_2011";

            var layerSource = new esri.layers.LayerDataSource({id:"NMG15012100001_2011"});
            layerSource.dataSource = dataSource;
           
          //笔者server上的图层-----http://localhost:6080/arcgis/rest/services/tdlytest/MapServer
            var featureLayer = new FeatureLayer("http://127.0.0.1:6080/arcgis/rest/services/tdlytest/MapServer/dynamicLayer",{  
                //注意这里的mode一定要指定MODE_SNAPSHOT，否则每次放大或缩小或者是平移都会执行FeatureLayer的update-end操作  
                mode: FeatureLayer.MODE_SNAPSHOT,  //MODE_ONDEMAND--MODE_SNAPSHOT
                source: layerSource,
                outFields: ["*"]  
            }); 
            //featureLayer.source = layerSource;
            featureLayer.id = "neidynamicLayer";
           var defn = new TimeExtent();
            var nowtime = new Date();
            console.log("now date---:----"+nowtime); 
            defn.startTime = new Date(nowtime);
            defn.endTime = new Date(new Date().getTime() + 60000);
            featureLayer.setTimeDefinition(defn);
            featureLayer.setDefinitionExpression("OBJECTID >=0");
            
            //定义线符号
            var lineSymbol=new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASH, new Color([255, 0, 0,0.2]), 3);
            //定义面符号
            var fill=new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, lineSymbol,new Color("#EEEE00"));
            //定义唯一值渲染器，对字段alias进行渲染，fill是默认的渲染符号
            var renderer = esri.renderer.UniqueValueRenderer(fill, "LD2011F");//new UniqueValueRenderer(fill, "LD2011F");
            //设置渲染的方式
            renderer.addValue("2", new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, lineSymbol,new Color("#458B00")));
            renderer.addValue("3", new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, lineSymbol,new Color("#90EE90")));
            renderer.addValue("4",new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, lineSymbol,new Color("#4169E1")));
            renderer.addValue("5", new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, lineSymbol,new Color("#CD2626")));
            renderer.addValue("6", new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, lineSymbol,new Color("#4169E1")));
            renderer.addValue("1", new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, lineSymbol,new Color("#9932CC")));
            
           	//定义一个render对FeatureLayer自定义的数据进行渲染  
            //var renderer = new SimpleRenderer(new SimpleFillSymbol().setOutline(new SimpleLineSymbol().setWidth(0.1).setColor(new Color([255, 0, 0]))));  
            /*renderer.setColorInfo({
                //使用nico属性进行渲染  
                field: "nico",  
                minDataValue: 0,  
                maxDataValue: 40,  
                colors: [  
                    new Color([0, 255, 0]),  
                    new Color([255, 0, 0])  
                ]  
            }); */
            //featureLayer.setRenderer(renderer);
            //featureLayer.redraw(); 
            featureLayer.on("update-end", function (evt) {  
                alert("test");
                featureLayer.setRenderer(renderer);  
                featureLayer.redraw(); 
                console.log("10th graphic attributes in featureLayer:"); 
            });         
            
            
            var shengLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://127.0.0.1:6080/arcgis/rest/services/tdlytest/MapServer", { "id": "mymaplayer" })
            //map.addLayer(shengLayer);
            map.addLayer(featureLayer);  

            /*if (featureLayer.loaded) {        
                 buildLayerList(featureLayer);              
             }else{
                 dojo.connect(featureLayer,"onLoad",buildLayerList);
             } */
            //定义线符号
            //var lineSymbol=new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASH, new Color([255, 0, 0]), 3);//替代defaultSymbol
            //定义面符号
            //var renderer = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, SimpleLineSymbol.STYLE_DASH,new Color("#FFFFCC"));//不需要定义唯一值渲染器，对字段alias进行渲染，fill是默认的渲染符号
            
            //featureLayer.setRenderer(renderer);  
            //featureLayer.redraw();  
          	//map.addLayer(layer);
            //AddDynamicLayer1();
    		var resizeTimer;
    		dojo.connect(map, 'onLoad', function(theMap) {
      			dojo.connect(dijit.byId('map'), 'resize', function() {
        			clearTimeout(resizeTimer);
        			resizeTimer = setTimeout(function() {
          				map.resize();
          				map.reposition();
         			}, 500);
       			});
     		});
       });
          
    }


    var myMap,selExtent,selgeometry,selobjectid,selAttributes;

    function getgraphicsLayerById(lyrname){
        var imagelayer = null;
        for(var nid in myMap.graphicsLayerIds){
            //var lyr = myMap.getLayer(nid);
            if(myMap.graphicsLayerIds[nid] === lyrname){
                imagelayer = myMap.getLayer(lyrname);
            }
        }
        return imagelayer;
    };

    function geoCoord2Pixel(geoCoord) {
        var pos;
        require([
            "esri/geometry/Point"
        ], function (Point) {
            var point = new Point(geoCoord[0], geoCoord[1]);
            pos = myMap.toScreen(point);
        });
        return [pos.x, pos.y];
    };

    function showsPage() {
        require([
            "esri/symbols/SimpleMarkerSymbol",
            "esri/symbols/SimpleLineSymbol",
            "esri/symbols/SimpleFillSymbol",
            "esri/symbols/PictureFillSymbol",
            "esri/geometry/Polygon", 
            "esri/SpatialReference"
        ], function (
            SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol,PictureFillSymbol,Polygon, SpatialReference
        ) {
            myMap.graphics.clear();
            QueryTask = new esri.tasks.QueryTask("https://localhost:6443/arcgis/rest/services/rsdbtest/ImageServer");
            query = new esri.tasks.Query();
            var whereStr = " NAME = '"+$("input[id='rsname']").val()+"'";//tm12603220110528432'";
            query.where = whereStr;
            query.outFields = ["*"];
            query.returnGeometry = true;
            QueryTask.execute(query, function (queryResult) {
                //alert(queryResult.features.length);
                var symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
                    new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT,
                    new dojo.Color([255, 0, 0]), 2), new dojo.Color([255, 255, 0, 0.25])
                );
                
                var spatialRef = new esri.SpatialReference('PROJCS["alb110-wgs84",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Albers"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",110.0],PARAMETER["Standard_Parallel_1",25.0],PARAMETER["Standard_Parallel_2",47.0],PARAMETER["Latitude_Of_Origin",12.0],UNIT["Meter",1.0]] ');
                var d_xmin = 0, d_ymin = 0, d_xmax = 0, d_ymax = 0;
                if (queryResult.features.length > 0) {
                    var graphic = new esri.Graphic();
                    var polygon = queryResult.features[0].geometry;
                    selAttributes = queryResult.features[0].attributes;
                    selobjectid = selAttributes.OBJECTID;
                    selgeometry =polygon;
                    var polygonExtent = polygon.getExtent();
                    selExtent = [polygonExtent.xmin,polygonExtent.ymin,polygonExtent.xmax,polygonExtent.ymax];
                    
                    graphic.setGeometry(queryResult.features[0].geometry);
                    graphic.setSymbol(symbol);
                    //myMap.graphics.add(graphic);
                    myMap.setExtent(polygonExtent);
                }
            });
        });
    }

    function updateImg(){
        require([
            "dojo/on",
            "esri/symbols/SimpleLineSymbol",
            "esri/symbols/PictureFillSymbol",
            "esri/geometry/Polygon", 
            "esri/SpatialReference",
            "esri/layers/GraphicsLayer"
        ], function (on,SimpleLineSymbol,PictureFillSymbol,Polygon, SpatialReference,GraphicsLayer) {
            var imagelayer = getgraphicsLayerById("imageshowlayer");
            var img_Graphics = imagelayer.graphics;
            //imagelayer.clear();
            for (var i in img_Graphics) {
                o_Graphic = img_Graphics[i];
                var polygon = o_Graphic.geometry;
                var polygonExtent = polygon.getExtent();
                selExtent = [polygonExtent.xmin, polygonExtent.ymin, polygonExtent.xmax, polygonExtent.ymax];
                var minpoint = geoCoord2Pixel([selExtent[0], selExtent[1]]);
                var maxpoint = geoCoord2Pixel([selExtent[2], selExtent[3]]);
                console.log(minpoint);
                console.log(maxpoint);
                var url = 'https://localhost:6443/arcgis/rest/services/rsdbtest/ImageServer/' + selobjectid + '/image?bbox=' + selExtent[0] + ',' + selExtent[1] + ',' + selExtent[2] + ',' + selExtent[3] + '&bandIds=0,1,2&f=image&format=png8&size=' + Math.abs(maxpoint[0] - minpoint[0]) + ',' + Math.abs(maxpoint[1] - minpoint[1]);
                console.log(url);
                var pfs = new PictureFillSymbol(url,//'img/test/image.png',//
                    new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
                        new dojo.Color('#000'), 1),
                    Math.abs(maxpoint[0] - minpoint[0]), Math.abs(maxpoint[1] - minpoint[1]));
                pfs.setOffset(maxpoint[0], maxpoint[1]);
                //pfs.setXScale(2.1);
                //o_Graphic.setGeometry(polygon);//);//selgeometry
                //o_Graphic.setAttributes(selAttributes);
                o_Graphic.setSymbol(pfs);
                //myMap.graphics.add(graphic);
                //将图形添加到图层中
                //graphicsLayer.add(o_Graphic);
            }
        });
        
        
        //var spatialRef = new esri.SpatialReference('PROJCS["alb110-wgs84",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Albers"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",110.0],PARAMETER["Standard_Parallel_1",25.0],PARAMETER["Standard_Parallel_2",47.0],PARAMETER["Latitude_Of_Origin",12.0],UNIT["Meter",1.0]] ');
        //var polygon = new Polygon(new SpatialReference('PROJCS["alb110-wgs84",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Albers"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",110.0],PARAMETER["Standard_Parallel_1",25.0],PARAMETER["Standard_Parallel_2",47.0],PARAMETER["Latitude_Of_Origin",12.0],UNIT["Meter",1.0]]'));
        //polygon.addRing([[selExtent[0], selExtent[1]], [selExtent[0], selExtent[3]], [selExtent[2], selExtent[3]], [selExtent[2], selExtent[1]], [selExtent[0], selExtent[1]]]);
    }
    
    function showImg(){
        require([
            "dojo/on",
            "esri/symbols/SimpleLineSymbol",
            "esri/symbols/PictureFillSymbol",
            "esri/geometry/Polygon", 
            "esri/SpatialReference",
            "esri/layers/GraphicsLayer"
        ], function (on,SimpleLineSymbol,PictureFillSymbol,Polygon, SpatialReference,GraphicsLayer) {
            //创建客户端图层
            var graphicsLayer=new GraphicsLayer();
            graphicsLayer.id = "imageshowlayer";
            //将客户端图层添加到地图中
            myMap.addLayer(graphicsLayer);
            
            var graphic = new esri.Graphic();
            var minpoint = geoCoord2Pixel([selExtent[0], selExtent[1]]);
            var maxpoint = geoCoord2Pixel([selExtent[2], selExtent[3]]);
            console.log(minpoint);
            console.log(maxpoint);
            var spatialRef = new esri.SpatialReference('PROJCS["alb110-wgs84",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Albers"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",110.0],PARAMETER["Standard_Parallel_1",25.0],PARAMETER["Standard_Parallel_2",47.0],PARAMETER["Latitude_Of_Origin",12.0],UNIT["Meter",1.0]] ');
            var polygon = new Polygon(new SpatialReference('PROJCS["alb110-wgs84",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Albers"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",110.0],PARAMETER["Standard_Parallel_1",25.0],PARAMETER["Standard_Parallel_2",47.0],PARAMETER["Latitude_Of_Origin",12.0],UNIT["Meter",1.0]]'));
            polygon.addRing([[selExtent[0], selExtent[1]],[selExtent[0], selExtent[3]],[selExtent[2], selExtent[3]],[selExtent[2], selExtent[1]],[selExtent[0], selExtent[1]]]);    
            var url = 'https://localhost:6443/arcgis/rest/services/rsdbtest/ImageServer/'+selobjectid+'/image?bbox='+selExtent[0]+','+selExtent[1]+','+selExtent[2]+','+selExtent[3]+'&bandIds=0,1,2&f=image&format=png8&size='+Math.abs(maxpoint[0] - minpoint[0])+','+Math.abs(maxpoint[1] - minpoint[1]);
            console.log(url);
            var pfs = new PictureFillSymbol(url,//'img/test/image.png',//
                new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
                    new dojo.Color('#000'), 1),
                Math.abs(maxpoint[0] - minpoint[0]), Math.abs(maxpoint[1] - minpoint[1]));
            console.log('--------------------------------------------------------');
            console.log(Math.abs(maxpoint[0] - minpoint[0]));
            console.log( Math.abs(maxpoint[1] - minpoint[1]));
            pfs.setOffset(maxpoint[0], 0);
            //pfs.setXScale(2.1);
            console.log(selExtent);
            graphic.setGeometry(polygon);//);//selgeometry
            graphic.setAttributes(selAttributes);
            graphic.setSymbol(pfs);
            //myMap.graphics.add(graphic);
            //将图形添加到图层中
            graphicsLayer.add(graphic);
            //绑定事件
            on(graphicsLayer,"click",function(event){
                var graphic=event.graphic;
                alert(graphic.attributes["NAME"]);
            });
            //绑定scale-range-change事件
            on(myMap,"zoom-end", function(event){
                console.log("extent-change-----------------");
                updateImg();
            });
            /*on(myMap,"mouse-up", function(event){
                console.log("mouse-up-----------------");
                updateImg();
            });*/
           // myMap.setExtent(polygonExtent);
        });
    }

    function imageinit(){
         require([ 
            "esri/TimeExtent",
            "esri/layers/FeatureLayer",  
            "esri/renderers/SimpleRenderer",  
            "esri/Color",  
            "esri/symbols/SimpleFillSymbol",  
            "esri/symbols/SimpleLineSymbol",
            "esri/layers/MapImageLayer"
        ], function(TimeExtent,FeatureLayer,SimpleRenderer,Color,SimpleFillSymbol,SimpleLineSymbol,TableDataSource,ImageServiceParameters,MapImageLayer,MapImage) {
            var spatialRef = new esri.SpatialReference('PROJCS["alb110-wgs84",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Albers"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",110.0],PARAMETER["Standard_Parallel_1",25.0],PARAMETER["Standard_Parallel_2",47.0],PARAMETER["Latitude_Of_Origin",12.0],UNIT["Meter",1.0]]');//'PROJCS["WGS_1984_Albers",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Albers"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",105.0],PARAMETER["Standard_Parallel_1",25.0],PARAMETER["Standard_Parallel_2",47.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]');
        var startExtent = new esri.geometry.Extent();
        startExtent.xmin = -1033743.8509;
        startExtent.ymin = 2811607.7306;
        startExtent.xmax = 1146479.9894;
        startExtent.ymax = 4614353.5503;
        startExtent.spatialReference = spatialRef;
        myMap = new esri.Map("map", { extent: startExtent });
        var myDynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://localhost:6080/arcgis/rest/services/bhq/MapServer",{id:"titllayer"});
        //var myDynamicMapServiceLayertest = new esri.layers.ArcGISDynamicMapServiceLayer(FeatureServer_Map_url+"/8");
        myMap.addLayer(myDynamicMapServiceLayer);
        //var layer = new esri.layers.ArcGISImageServiceVectorLayer("http://localhost:6080/arcgis/rest/services/rsdbtest/ImageServer");
        //var layer = new esri.layers.ArcGISImageServiceVectorLayer("https://localhost:6443/arcgis/rest/services/rsdbtest/ImageServer");
        var imageExtent = new esri.geometry.Extent();
        imageExtent.xmin = -30473.03849999979;
        imageExtent.ymin = 3168657.4595;
        imageExtent.xmax = 196637.03049999848;
        imageExtent.ymax = 3407320.3752999995;
        imageExtent.spatialReference = spatialRef;
        var params = new ImageServiceParameters();
        params.noData = 0;
        params.extent=imageExtent;
        var layer = new esri.layers.ArcGISImageServiceLayer("https://localhost:6443/arcgis/rest/services/rsdbtest/ImageServer");/*, {
          imageServiceParameters: params,
          opacity: 0.75
        });*/
        /*var mi = new MapImage({
            'extent': imageExtent,
            'href': "https://localhost:6443/arcgis/rest/services/rsdbtest/ImageServer/2/image"
        });
        var myMapImageLayer = MapImageLayer("https://localhost:6443/arcgis/rest/services/rsdbtest/ImageServer/2/image");
        myMapImageLayer.addImage(mi);*/
        //var renderer = new SimpleRenderer(new SimpleFillSymbol().setOutline(new SimpleLineSymbol().setWidth(0.1).setColor(new Color([255, 0, 0]))));  
        //layer.setRenderer(renderer);    

        //myMap.addLayer(layer);
        //showsPage(myMap);
        var resizeTimer;
    	dojo.connect(map, 'onLoad', function(theMap) {
      		dojo.connect(dijit.byId('map'), 'resize', function() {
        		clearTimeout(resizeTimer);
        		resizeTimer = setTimeout(function() {
          			map.resize();
          			map.reposition();
         		}, 500);
       		});
     	});
        });
        
    }
imageinit();

</script> 
</head> 
<input type="button" value="test" onclick="AddDynamicLayer1();"/>
<input type="button" value="imgseach" onclick="showsPage();"/>
<input type="button" value="showimg" onclick="showImg();"/>
<input type="text" value="LS8_127031_20150802" id="rsname"/>
</br>
<body class="tundra"> 
	<div dojotype="dijit.layout.BorderContainer" design="headline" gutters="true" style="width: 100%; height: 100%; margin: 0;"> 
		<div id="map" dojotype="dijit.layout.ContentPane" region="center"> </div> 
	</div> 
</body>
</html>